package site.fantasycube.blog.util.result;

/**
 * @author 幻&乐
 * @Date 2021/12/26
 * 描述 公共返回对象
 */
public class BaseResult {

    /**
     *描述：状态码
     * 默认成功 200
     */
    private Integer code;

    /**
     *描述：操作信息
     * 默认操作成功
     */
    private String message;

    /**
     *描述：返回对象
     */
    private Object data;
    /**
     *描述：操作结果布尔值
     */
    private Boolean success;

    public BaseResult() {
    }

    public static BaseResult result(Boolean res){
        if (res){
            return Success.me();
        }else {
            return Fail.me();
        }
    }

    public BaseResult(Integer code, String message, Object data ,Boolean buer) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.success = buer;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public BaseResult setData(Object data) {
        this.data = data;
        return this;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }
}
